<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html;charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>国家公路网综合养护管理系统-欢迎注册</title>
<link rel='icon' th:href="@{/favicon.ico}" type='image/x-icon' />
<block th:replace="commonBase"></block>
<!-- LayUI -->
<link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}"/>
<link rel="stylesheet" th:href="@{/plugins/layui/css/layui.css}"/>
<link rel="stylesheet" th:href="@{/plugins/steps/css/jquery.step.css}" />
<script th:src="@{/plugins/steps/js/jquery.steps.js}"></script>
<script th:src="@{/plugins/steps/js/md5.js}"></script>
<script th:src="@{/plugins/layui/layui.js}" type="text/javascript"></script>
<style type="text/css">
body {
	font-family: '微软雅黑'
}
a{
	font-family: '微软雅黑'	
}
span {
	font-family: '微软雅黑'	
}
.layui-btn{
height: 38px;
line-height: 38px;
margin-left:15px;
}
.layui-input-block{
	margin-left: 35% !important;
}
.layui-form-item{
	margin-bottom: 18px !important;
}
.stepBtn{
	text-align: center;margin-top: 30px;
}
.apply-finish-msg{
	font-weight: 700;
	font-size: 24px;
	color: #009899;
	margin-top: 30px
}



/*以下样式是从miniui的themes/cupertino/skin.css文件中摘出来的，更改background为纯白色*/
.mini-widget-content,
body, .mini-popup, .mini-toolbar, .separator, .mini-panel-border, .mini-pager,
.mini-panel-toolbar, .mini-panel-footer, .mini-panel-viewport, .mini-window .mini-panel-footer,
.mini-outlookbar-border, .mini-outlookbar .mini-outlookbar-group, .mini-outlookbar .mini-outlookbar-groupBody, .mini-outlookbar-view2 .mini-outlookbar-groupBody, mini-outlookbar-view3 .mini-outlookbar-group,
.mini-splitter-border, .mini-splitter .mini-splitter-pane1, .mini-splitter .mini-splitter-pane2,
.mini-layout-border, .mini-layout-region,
.mini-menu, .mini-menu-border, .mini-menu-horizontal .mini-menu-border
.mini-grid-border, .mini-grid-footer, .mini-grid-pager, .mini-grid-filterRow, .mini-grid-groupCell, .mini-grid-summaryCell,
.mini-listbox-border,
.mini-progressbar-border,
.mini-calendar, .mini-calendar-footer, .mini-calendar-menu,
.mini-tabs-bodys, .mini-tabs .mini-tabs-space, .mini-tabs .mini-tabs-space2, .mini-tabs .mini-tab-active,
.mini-textbox-border,
.mini-buttonedit-border,
.mini-textboxlist-border, .mini-tooltip-inner,
body .mini-pager-num
{
	border-color:#e6e6e6;
	background:#fff;
	color:#757575;
	border-radius: 3px;
}

.mini-textbox-input, .mini-buttonedit-input, .mini-menuitem-text, .mini-menuitem-text a {
    color: #757575;
}


/*重写弹出窗样式*/
 .mini-panel-border
{
	border-color:#e6e6e6;
	background:#fff;
	color:#757575;
}
</style>
</head>
<body>
    <div style="padding: 20px; background-color: #F2F2F2;">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-header"><span style="color: #e51c23;font-size:20px;font-weight: 700;">欢迎注册国家公路网综合养护管理系统</span>
        
        </div>
        <div class="layui-card-body" id="bodyContent">
          
          <form id="editForm1" class="layui-form" action="" style="font-family:'微软雅黑';font-size:12px;line-height:1.28571;margin-top:0px;">
          <div class="step-body" id="myStep">
			<div style="position:relative;right: 40px;font-size: 12px;color: #73777a;letter-spacing:0.4px;line-height: 30px;text-align: right;">
        			<span class="tips-text">已有系统账号？</span><a style="color:#00b7d3;" th:href="@{/index}" target="_top"><!-- react-text: 6 --> <!-- /react-text --><!-- react-text: 7 -->快捷登录 &gt;<!-- /react-text --></a>
        		</div>
			<div class="step-header" style="width: 80%; display: block;">
				<ul>
				<li class="step-active" style="width: 25%;"><p>基本信息</p></li>
				<!-- <li style="width: 25%;"><p>单位信息</p></li> -->
				<li style="width: 25%;"><p>注册须知</p></li>
				<li style="width: 25%;"><p>完成</p></li>
				</ul>
				
			</div>
			
			<div class="step-content">
			<div class="step-list" style="margin: 120px auto;">
			
				<div class="layui-form-item">
					    <div class="layui-input-block">
					       <div style="float: left;line-height: 40px;color: #111;font-size: 13px;"><span style="color: red;">*</span> 登录账号：&nbsp;&nbsp;</div><input type="text" id="userid" name="userid" autocomplete="off" placeholder="设置登录账号" class="layui-input" style="width:300px;" lay-verify="required|userCode" />
					      <span style="position: absolute;top: 40px;" id="message"></span>
					    </div>
					  </div>
				<!-- <div class="layui-form-item">
					    <div class="layui-input-block">
					      <div style="float: left;line-height: 40px;color: #111;font-size: 13px;"><span style="color: red;">  &nbsp;&nbsp;*</span> 姓      &nbsp;&nbsp;&nbsp;  名：&nbsp;&nbsp;</div><input type="text" id="username" name="username" autocomplete="off" placeholder="设置真实姓名" class="layui-input" style="width:300px;"  />
					      <span style="position: absolute;top: 40px;" id="message"></span>
					    </div>
					  </div>	   -->
				<div class="layui-form-item">
					    <div class="layui-input-block">
					      <div style="float: left;line-height: 40px;color: #111;font-size: 13px;"><span style="color: red;">*</span> 登录密码：&nbsp;&nbsp;</div><input type="password" id="password" name="password" lay-verify="required|pass"  autocomplete="off" placeholder="设置你的登录密码" class="layui-input" style="width:300px;" />
					      <span style="position: absolute;top: 40px;" id="passwordmessage"></span>
					    </div>
					  </div>
        			<div class="layui-form-item">
					    <div class="layui-input-block">
					      <div style="float: left;line-height: 40px;color: #111;font-size: 13px;"><span style="color: red;">*</span> 确认密码：&nbsp;&nbsp;</div><input type="password" id="confirmPassword" name="confirmPassword" lay-verify="conpas"  autocomplete="off" placeholder="请再次输入你的密码" class="layui-input" style="width:300px;" />
					      <span style="position: absolute;top: 40px;" id="conpaswordmessage"></span>
					    </div>
					  </div>
        			<div class="layui-form-item">
					    <div class="layui-input-block">
					      <div style="float: left;line-height: 40px;color: #111;font-size: 13px;"><span style="color: red;">*</span> 手机号码：&nbsp;&nbsp;</div><input type="text" id="phone" name="phone" lay-verify="phone" autocomplete="off" placeholder="请输入手机号码" class="layui-input" style="width:300px;" />
					      <span style="position: absolute;top: 40px;" id="phonemessage"></span>
					    </div>
					  </div>
        			<div class="layui-form-item">
        				 <div class="layui-input-block">
					      <div style="float: left;line-height: 40px;color: #111;font-size: 13px;"><span style="color: red;"> &nbsp;*</span>  验&nbsp;证&nbsp;码：&nbsp;&nbsp;</div><input type="text" name="vercode" id="LAY-user-login-vercode"  placeholder="验证码" class="layui-input" style="width: 185px;" />
					      <button type="button" class="layui-btn layui-btn-primary" id="LAY-user-getsmscode" style="position:absolute;top: 0;left: 175px;" >获取验证码</button>
					    </div>

					  </div>
        			<!-- <div class="layui-form-item">
        				 <div class="layui-input-block">
					      <div style="float: left;line-height: 40px;color: #111;font-size: 13px;"> &nbsp;&nbsp;&nbsp;&nbsp;邮      &nbsp;&nbsp;&nbsp;  箱：&nbsp;&nbsp;</div><input type="text" name="email" id="email" lay-verify="email" placeholder="电子邮箱" class="layui-input" style="width:300px;" />
					      <span style="position: absolute;top: 40px;" id="emailmessage"></span>
					    </div>

					  </div> -->
					
			
		<!-- 	</div>
			<div class="step-list" style="margin: 120px auto;"> -->
			<!-- <div class="layui-form-item"> -->
        				 <!-- <div class="layui-input-block">
					      <input type="text" name="zone" id="zone" placeholder="区号" disabled="" class="layui-input" style="width:80px;height: 38px;font-size:14px;line-height: 35px;border: 1px solid #e6e6e6;color:#9b9ea0;margin-right: 1px;position: relative;margin-bottom: -38px;" />
					      <input type="text" name="telephone" id="telephone" lay-verify="required" placeholder="固定电话" class="layui-input" style="width:219px;margin-left:81px;" />
					      <span style="position: absolute;top: 40px;" id="telephonemessage"></span>
					    </div> -->

					  <!-- </div> -->
					  <div class="layui-form-item">
        				 <div class="layui-input-block" style="text-align: left;">
					      <input type="radio" name="optionsRadiosinline" id="managergov" value="管理机构" title="管理机构" checked=""  lay-filter="optionsRadiosinline"/>
					     <input type="radio" name="optionsRadiosinline" id="person" value="科研用户" title="科研用户"  lay-filter="optionsRadiosinline"  />
					    </div>
					  </div>
					  
					 <div  id="shengshi">
					    <div class="layui-input-block">
					    	<input id="orgCombo1" onvaluechanged="onDeptChanged1"  class="mini-combobox" style="width:260px;" textField="name" valueField="id"  />
					    	<input id="orgCombo11"  onvaluechanged="onDeptChanged11"  class="mini-combobox" style="width:250px;display: none;" textField="name" valueField="id" />
					    	<input id="orgCombo111" onvaluechanged="onDeptChanged111"  class="mini-combobox" style="width:250px;display: none;" textField="name" valueField="id" />
					    	<!-- <input id="orgCombo1111" onvaluechanged="onDeptChanged1111"  class="mini-combobox" style="width:150px;display: none;" textField="name" valueField="id" required="true" allowInput="true"  emptyText="请选择单位" showNullItem="false" /> -->
						</div>
					</div>
					
					 <div  id="keyandanwei" style="display:none;">
					    <div class="layui-input-block">
					    	<input id="orgCombo2" class="mini-combobox" style="width:150px;" textField="name" valueField="id" height="38" /> 
						</div>
					</div>
					
			<!-- 		<div class="layui-form-item" id="gydwidipt"  style="display:none;">
					    <div class="layui-input-block" >
					    	 <input type="text" name="company" id="company"  class="layui-input" placeholder="单位名称" maxLength="40"  style="width:300px;" />
					    	 <span style="position: absolute;top: 40px;" id="companymessage"></span>
					    </div>
					  </div> -->
					  
					  <div class="stepBtn">
						<button type="button" class="layui-btn layui-btn-normal" id="applyBtn">下一步</button>
					</div>
				<!-- <div class="stepBtn">
						<button type="button" class="layui-btn layui-btn-normal" id="preBtn">上一步</button>
						<button type="button" class="layui-btn layui-btn-normal" id="nextBtn">下一步</button>
					</div>
			 -->
			</div>
			<div class="step-list" style="margin: 120px auto;">
				
				
				<div class="layui-form-item" >
					<span style="margin-left: 45%;line-height:42px;font-size: 14px;color: #111;">用户注册须知</span>
					<div style="margin-left: 10%;margin-right: 10%;line-height: 28px;">
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;国家公路网综合养护管理系统的用户群为部、省、市级机构用户以及科研单位，用于路面养护的综合性养护管理系统，
						    	用户注册成功后，用户为不可激活状态，需联系管理员进行开通。系统审核员会对您的身份进行审核，审核通过您就可以正常登录系统。对于非法注册的用户，系统管理员会对用户进行销户处理。
						    	在确认充分理解后选择接受或不接受本服务条款；一旦您完成“同意条款并注册”或开始以其他方式使用系统，即表明您已阅读并同意受本服务条款的约束。如您不同意本服务条款或其中任何条款约定，您应不再进行下一步或停止注册程序。
系统再次提示您审慎阅读、充分理解各条款内容。
				   </div>
			   </div>
				<div class="stepBtn">
						<button type="button" class="layui-btn layui-btn-normal" id="pre2Btn">上一步</button>
						<button  class="layui-btn" lay-submit="" id="register" lay-filter="register">同意条款并注册</button>
					</div>
			</div>
			
			<div class="step-list" style="margin: 120px auto;">
			
			<div class="apply-finish" style="text-align: center;">
				<div class="apply-finish-header">
				<img th:src="@{/plugins/steps/images/success.png}" />
				<div class="apply-finish-msg">恭喜，注册成功！</div>
				</div>
				<div class="apply-finish-footer" style="margin: 20px -10px;">
				<p><button type="button" class="layui-btn"  onclick="location.href='/crms/index'">立即登录</button></p>
				</div>
				</div>
			
			</div>
			</div>
			
			
			</div>
          </form>
          
          
          
          
        </div>
      </div>
    </div>
  </div>
</div> 

<script th:inline="javascript" type="text/javascript">
/*<![CDATA[*/

	
	

var basePath = /*[[@{/}]]*/

var layer=null;
var element = null;
var laypage =null;
var form=null;
var table = null;
var grid = null;
layui.use(['layer','element','form','table'], function(){ //独立版的layer无需执行这一句
	  var $ = layui.jquery, layer = layui.layer,
	   element = layui.element,form = layui.form,table = layui.table;
});	

/**
 * 特殊文本框长度设置
 * @returns
 */
function specialInputLengthSet(){
	//限制input框 最多输入50个字符
	$('input').maxLength(25);  
	//配置地址栏最多输入300字符
	$("input[name='email']").maxLength(45);
}
	
var height = $(window).height();
$("#bodyContent").height(height- 105 );
	var step= $("#myStep").step({
	animate:true,
	initStep:1,
	speed:1000
});
	var orgId = "";
	var orgName = "";
	//个人基本信息
	$("#applyBtn").click(function(event) {
		if($("#userid").val()==""){
			 $("#message").css("color","#FF5722");
			 $("#message").html("<i class='fa fa-remove'></i> 请填写用户名");
			 return false;
		}
		var userCls = $("#message").find("i").eq(0).attr("class");
		if(userCls.indexOf("remove")>=0){
			layer.msg("该用户名已注册");
			return false;
		}
		if($("#password").val()==""){
			 $("#passwordmessage").css("color","#FF5722");
			 $("#passwordmessage").html("<i class='fa fa-remove'></i> 请填写密码");
			 layer.msg("请填写密码");
			 return false;
		}
		var pasCls = $("#passwordmessage").find("i").eq(0).attr("class");
		if($("#confirmPassword").val()==""){
			 $("#conpaswordmessage").css("color","#FF5722");
			 $("#conpaswordmessage").html("<i class='fa fa-remove'></i> 请再次填写密码");
			 layer.msg("请再次填写密码");
			 return false;
		}
		var conpasCls = $("#conpaswordmessage").find("i").eq(0).attr("class");
		if(pasCls.indexOf("remove")>=0||conpasCls.indexOf("remove")>=0){
			layer.msg("两次输入的密码不一致");
			return false;
		}
		if($("#phone").val()==""){
			 $("#phonemessage").css("color","#FF5722");
			 $("#phonemessage").html("<i class='fa fa-remove'></i> 请填写手机号");
			 layer.msg("请填写手机号");
			 return false;
		}
		var phoneCls = $("#phonemessage").find("i").eq(0).attr("class");
		if(phoneCls.indexOf("remove")>=0){
			return false;
		}
		var text = $("#emailmessage").text();
		if(text.indexOf("已注册")>=0){
			layer.msg("请更换电子邮箱");
			return false;
		}

		if(xzjg == "科研用户"){
			 var company = $("#company").val();
		  	  if(company==""){
		  		 $("#companymessage").css("color","#FF5722");
				 $("#companymessage").html("<i class='fa fa-remove'></i> 管养单位名称不允许为空");
				 return false;
		  	  }
		  	 if(company.length>11){
		  		$("#companymessage").css("color","#FF5722");
				 $("#companymessage").html("<i class='fa fa-remove'></i> 管养单位名称过长，请修改");
				  return false;
		  	  }
		  	 orgId = "1014";//科研单位
		  	 orgName = "科研单位";
		}else{
			orgId = "";
			var deptCombo1 = mini.get("orgCombo1");
			var deptCombo2 = mini.get("orgCombo11");
			var deptCombo3 = mini.get("orgCombo111");

			//var flag1 =  $("#orgCombo1").is(':hidden');
			var flag11 =  $("#orgCombo11").is(':hidden');
			var flag111 =  $("#orgCombo111").is(':hidden');

			orgId = deptCombo1.getValue();//默认用第一档的
			orgName = deptCombo1.getText();

			if(!flag11){
				orgId = deptCombo2.getValue();
				orgName = deptCombo2.getText();
			}

			if(!flag11){
				orgId = deptCombo3.getValue();
				orgName = deptCombo3.getText();
			}

			if(orgId == ""){
				 $("#companymessage").html("<i class='fa fa-remove'></i> 管养单位名称不允许为空");
				 return false;
			}
		}
		// var yes=step.nextStep();
		
			var mobile = $("#phone").val();
		var code = $("#LAY-user-login-vercode").val();
		var index = layer.msg('正在验证', {icon: 16,time:0});
		$.ajax({
			  url:basePath+"users/checkuser",
			  type: 'get',
			  async:false,
			  data:{"username":orgName},
			  success: function (result) {
				  var message = result;
				  if(message == "1"){
					  layer.msg("该管养单位已注册");
					  return false;
				  }else{
					  $.ajax({
						  url:basePath+"users/checkuser",
						  type: 'get',
						  data:{mobile:mobile,code:code},
						  success: function (result) {
							  layer.close(index);
							  if(result == "0"){
								 layer.msg('您的验证码有误，请重新输入！',{icon:2},function(){
									 return false;
								 });
							  }
							  if(result == "1"){
								  layer.close(index);
								  var yes=step.nextStep();
							  }
						  },
						  error:function (XMLHttpRequest, textStatus, errorThrown) {
					        	 layer.msg("验证出错", {time: 2000, icon:2});
					        }
					  });

				 }
			  },
			  error:function (XMLHttpRequest, textStatus, errorThrown) {
		        	 layer.msg("验证出错", {time: 2000, icon:2});
		        	 return false;
		        }
		  });

		
	
	
		 
	});


	//单位信息
	$("#nextBtn").click(function(event) {
		if(xzjg == "科研用户"){
			 var company = $("#company").val();
		  	  if(company==""){
		  		 $("#companymessage").css("color","#FF5722");
				 $("#companymessage").html("<i class='fa fa-remove'></i> 管养单位名称不允许为空");
				 return false;
		  	  }
		  	 if(company.length>11){
		  		$("#companymessage").css("color","#FF5722");
				 $("#companymessage").html("<i class='fa fa-remove'></i> 管养单位名称过长，请修改");
				  return false;
		  	  }
		  	 orgId = "1014";//科研单位
		}else{
			orgId = "";
			var deptCombo1 = mini.get("orgCombo1");
			var deptCombo2 = mini.get("orgCombo11");
			var deptCombo3 = mini.get("orgCombo111");

			//var flag1 =  $("#orgCombo1").is(':hidden');
			var flag11 =  $("#orgCombo11").is(':hidden');
			var flag111 =  $("#orgCombo111").is(':hidden');

			orgId = deptCombo1.getValue();//默认用第一档的

			if(!flag11){
				orgId = deptCombo2.getValue();
			}

			if(!flag11){
				orgId = deptCombo3.getValue();
			}

			if(orgId == ""){
				 $("#companymessage").html("<i class='fa fa-remove'></i> 管养单位名称不允许为空");
				 return false;
			}
		}
		 var yes=step.nextStep();
	});
	$("#preBtn").click(function(event) {
		var yes=step.preStep();
	});

	$("#pre2Btn").click(function(event) {
		var yes=step.preStep();
	});

	function dealKydw(gydata){
		//var kydata = [];
		//var kyobj = {};
		//kyobj.id = "010101";
		//kyobj.name = "科研单位";
		//kydata.push(kyobj);
		//mini.get("orgCombo2").setData(kydata);
		//mini.get("orgCombo2").setValue("010101");
		var orgComboxList1 = mini.decode(gydata);
		var orgArr = [];
		for(var i=0;i<orgComboxList1.length;i++){
			var orgData = orgComboxList1[i];
			var orgpid = orgData.parentId;
			var orgId = orgData.id;
			if(orgpid == "1014"){
				var orgObj = {};
				orgObj.id = orgId;
				orgObj.name = orgData.orgName;
				orgArr.push(orgObj);
			}
		}
		var deptCombo1 = mini.get("orgCombo2");
		deptCombo1.setData(orgArr);
		deptCombo1.select(0);
	}
	var deptCombo =null;
	var orgComboxList =  null;
	function dealgydw(gydata){
		orgComboxList = mini.decode(gydata);
		var orgArr = [];
		for(var i=0;i<orgComboxList.length;i++){
			var orgData = orgComboxList[i];
			var orgLevel = orgData.orgLevel;
			var orgId = orgData.id;
			if(orgLevel == "2" || orgId == "37"){
				var orgObj = {};
				orgObj.id = orgId;
				orgObj.name = orgData.orgName;
				orgArr.push(orgObj);
			}
		}
		deptCombo = mini.get("orgCombo1");
		deptCombo.setData(orgArr);
		deptCombo.setValue("9");
		onDeptChanged1();
	}

	//组织机构切换
	function onDeptChanged1(){
		deptCombo = mini.get("orgCombo1");
		var id = deptCombo.getValue();
		var firstId = ""; 
		var orgArr = [];
		for(var i=0;i<orgComboxList.length;i++){
			var orgData = orgComboxList[i];
			var orgLevel = orgData.orgLevel;
			var orgType = orgData.orgType;//组织类型不为10
			var orgId = orgData.id;
			var orgPId = orgData.parentId;
			if(orgLevel == "3" && orgPId ==  id && orgType != "10"){
				var orgObj = {};
				orgObj.id = orgId;
				orgObj.name = orgData.orgName;
				orgArr.push(orgObj);
				firstId = orgId;
			}
		}
		if(orgArr.length > 0){
			$("#orgCombo11").show();
			deptCombo = mini.get("orgCombo11");
			deptCombo.setData(orgArr);
			deptCombo.setValue(firstId);
			onDeptChanged11();//去触发第二级的改变事件
			
		}else{
			$("#orgCombo11").hide();
			$("#orgCombo111").hide();
			$("#orgCombo1111").hide();
		}
	
	}

	function onDeptChanged11(){
		deptCombo = mini.get("orgCombo11");
		var id = deptCombo.getValue();
		var firstId = ""; 
		var orgArr = [];
		for(var i=0;i<orgComboxList.length;i++){
			var orgData = orgComboxList[i];
			var orgLevel = orgData.orgLevel;
			var orgType = orgData.orgType;//组织类型不为10
			var orgId = orgData.id;
			var orgPId = orgData.parentId;
			if(orgLevel == "4" && orgPId ==  id && orgType != "10"){
				var orgObj = {};
				orgObj.id = orgId;
				orgObj.name = orgData.orgName;
				orgArr.push(orgObj);
				firstId = orgId;
			}
		}
		if(orgArr.length > 0){
			$("#orgCombo111").show();
			deptCombo = mini.get("orgCombo111");
			deptCombo.setData(orgArr);
			deptCombo.setValue(firstId);
		}else{
			$("#orgCombo11").hide();
			$("#orgCombo111").hide();
			$("#orgCombo1111").hide();
		}
	
	}


	var xzjg = "";
	var form=null;
	var tips="false";
	layui.use('form', function(){ //独立版的layer无需执行这一句
		 form = layui.form;

		//初始化加载 组织机构信息
		 $.ajax({
			 url:basePath+"org/list",
			 type: 'POST',
			 success : function(text) {
				dealgydw(text);//处理管养单位
				dealKydw(text);//处理科研单位的combox
			 },
			 error : function() {
			 }
		  });

		  
		
		 
		 var item = "";
		 form.on('radio(optionsRadiosinline)', function(data){
			  xzjg = data.value;
			  item = data.value;
			  if(item == "科研用户"){
					$("#gryh").attr("class","checked_span");
					$("#gljg").attr("class","unchecked_span");
					$("#jyqy").attr("class","unchecked_span");
					$("#qtqy").attr("class","unchecked_span");
					$("#shengshi").hide();
					$("#keyandanwei").show();
					$("#gydwidipt").show();
				}
				if(item == "管理机构"){
					$("#gryh").attr("class","unchecked_span");
					$("#gljg").attr("class","checked_span");
					$("#jyqy").attr("class","unchecked_span");
					$("#qtqy").attr("class","unchecked_span");
					$("#shengshi").show();
					$("#keyandanwei").hide();
					$("#gydwidipt").hide();
				}
			});
		 $("#userid").change(function(){
			 var value = $(this).val();
			 var uPattern = /^[a-zA-Z0-9_-]{3,16}$/;
			    if(uPattern.test(value)){
			    	$.ajax({
						  url:basePath+"users/checkuser",
						  type: 'get',
						  data:{"userid":value},
						  success: function (result) {
							  var message = result;
							  if(message == "1"){
								  $("#message").css("color","#FF5722");
								  $("#message").html("<i class='fa fa-remove'></i> 该用户名已注册");
							  }else{
								  $("#message").css("color","#4CAF50");
								  $("#message").html("<i class='fa fa-check'></i> 该用户名可用");
							  }
						  },
						  error:function (XMLHttpRequest, textStatus, errorThrown) {
					        	 layer.msg("验证出错", {time: 2000, icon:2});
					        }
					  });
			    }else{
			    	 $("#message").css("color","#FF5722");
					 $("#message").html("<i class='fa fa-remove'></i> 用户名必须为3~16个字符且不能含有特殊字符（如：\'_\',\'-\'等）");
			    }
			 
		 });
		 $("#password").change(function(){
			 var value = $(this).val();
			// var pPattern = /^[A-Za-z0-9]{6,16}$/;
			 var pPattern = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,20}');
			  if(!pPattern.test(value)){
				  $("#passwordmessage").css("color","#FF5722");
				  $("#passwordmessage").html("<i class='fa fa-remove'></i> 密码为8~20位的必须包含字母数字特殊字符组合");
			  }else{
				  $("#passwordmessage").css("color","#4CAF50");
				  $("#passwordmessage").html("<i class='fa fa-check'></i> 密码符合要求");
			  }
		 });
		 $("#confirmPassword").change(function(){
			 var value = $(this).val();
			 var pas = $("#password").val();
			 
			 var pPattern = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,20}');
			  if(!pPattern.test(value)){
				  $("#conpaswordmessage").css("color","#FF5722");
				  $("#conpaswordmessage").html("<i class='fa fa-remove'></i> 密码为8~20位的必须包含字母数字特殊字符组合");
			  }else{
				  if(value!=pas){
					  $("#conpaswordmessage").css("color","#FF5722");
					  $("#conpaswordmessage").html("<i class='fa fa-remove'></i> 两次输入的密码不一致");
				  }else{
					  $("#conpaswordmessage").css("color","#4CAF50");
					  $("#conpaswordmessage").html("<i class='fa fa-check'></i> 密码验证通过");
				  }
			  }
		 });
		 $("#phone").change(function(){
			 var value = $(this).val();
			 var mPattern = /^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0-9])|(17[0,5-9]))\d{8}$/;
			 if(!mPattern.test(value)){
				 $("#phonemessage").css("color","#FF5722");
				 $("#phonemessage").html("<i class='fa fa-remove'></i> 请输入正确的手机号码");
			 }else{
				 $.ajax({
					  url:basePath+"users/checkuser",
					  type: 'get',
					  data:{"phone":value},
					  success: function (result) {
						  var message = result;
						  if(message == "1"){
							  $("#phonemessage").css("color","#FF5722");
							  $("#phonemessage").html("<i class='fa fa-remove'></i> 该手机号已注册");
						  }else{
							  $("#phonemessage").css("color","#4CAF50");
							  $("#phonemessage").html("<i class='fa fa-check'></i> 该手机号可用");
						  }
					  },
					  error:function (XMLHttpRequest, textStatus, errorThrown) {
				        	 layer.msg("验证出错", {time: 2000, icon:2});
				        }
				  });
			 }
			 
		 });
		 $("#email").change(function(){
			 var value = $(this).val();
			 var ePattern = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			 if(!ePattern.test(value)){
				 $("#emailmessage").css("color","#FF5722");
				 $("#emailmessage").html("<i class='fa fa-remove'></i> 请输入正确的电子邮箱");
			 }else{
				 $.ajax({
					  url:basePath+"users/checkuser",
					  type: 'get',
					  data:{"email":value},
					  success: function (result) {
						  var message = result;
						  if(message == "1"){
							  $("#emailmessage").css("color","#FF5722");
							  $("#emailmessage").html("<i class='fa fa-remove'></i> 该电子邮箱已注册");
						  }else{
							  $("#emailmessage").css("color","#4CAF50");
							  $("#emailmessage").html("<i class='fa fa-check'></i> 该电子邮箱可用");
						  }
					  },
					  error:function (XMLHttpRequest, textStatus, errorThrown) {
				        	 layer.msg("验证出错", {time: 2000, icon:2});
				        }
				  });
			 }
		 });
		 $("#company").change(function(){
			 var value = $(this).val();
			  if(value.length>11){
				  $("#companymessage").css("color","#FF5722");
				  $("#companymessage").html("<i class='fa fa-remove'></i> 管养单位名称必须小于或等于22个字符");
			  }else{
				  $("#companymessage").css("color","#4CAF50");
				  $("#companymessage").html("<i class='fa fa-check'></i> 管养单位名称符合要求");
			  }
		 });
		//发送验证码
			$("#LAY-user-getsmscode").click(function(){
				var mobile = $("#phone").val(); 
				if(mobile==""){
					layer.msg("请输入正确的手机号");
					return false;
				}
				if(!checkCellphone(mobile)){
					layer.msg("手机号码有误，请重新输入");
					return false;
				}
				var text = $("#phonemessage").text();
				if(text.indexOf("已注册")>=0){
					layer.msg("请更换手机号");
					return false;
				}
				  var index = layer.msg('正在发送验证码', {icon: 16,time:0});
				$.ajax({
					  url:basePath+"users/sendcode/"+mobile,
					  type: 'get',
					  data:null,
					  success: function (result) {
						  layer.close(index);
						  if(result == "success"){
							  sendAgain();
						  }else{
							  layer.msg("验证码发送失败",{icon:2});
						  }
					  },
					  error:function (XMLHttpRequest, textStatus, errorThrown) {
				        	 layer.msg("验证出错", {time: 2000, icon:2});
				        }
				  });
			});
		 form.verify({
			 userCode: function(value, item){ //value：表单的值、item：表单的DOM对象
				 var uPattern = /^[a-zA-Z0-9_-]{3,16}$/;
			    if(!uPattern.test(value)){
			      return '用户名必须为3~16个字符且不能含有特殊字符（如：\'_\',\'-\'等）';
			    }else if(/^\d+\d+\d$/.test(value)){
			      return '用户名不能全为数字';
			    }
			  }, 
			  userName: function(value, item){ //value：表单的值、item：表单的DOM对象
					 var uPattern = /^[a-zA-Z0-9_-]{3,16}$/;
					    if(!uPattern.test(value)){
					      return '姓名必须为3~16个字符且不能含有特殊字符（如：\'_\',\'-\'等）';
					    }else if(/^\d+\d+\d$/.test(value)){
					      return '用户名不能全为数字';
					    }
					  }
			  
			  //我们既支持上述函数式的方式，也支持下述数组的形式
			  //数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
			  ,pass: function(value,item){
				  var pPattern = /^[A-Za-z0-9]{6,16}$/;
				  if(!pPattern.test(value)){
					  return "密码为6~16位的字母或数字组合";
				  }
			  },email:function(value,item){
				  if(value != ""){
					  	var ePattern = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
						 if(!ePattern.test(value)){
							 return  "请输入正确的电子邮箱";
						 }
				   }
			  }
			 
			});
	        form.on('checkbox(tips)', function(data){
	        	tips =  data.elem.checked;
	        });
		
	        form.on('submit(register)', function(data){
		        		
					 var sobj = data.field;//要提交的对象 
					 sobj.password = hex_md5(sobj.password);
					 sobj.confirmPassword = hex_md5(sobj.confirmPassword);
					 sobj.orgId = orgId;
					 sobj.username = orgName;
					  var index = layer.msg('正在注册，请稍候', {icon: 16});
					  $.ajax({
					        url: basePath+"users/signup",
							type: 'post',
					        data: {data:JSON.stringify(sobj)},
					        success: function (successData) {
					        	var obj = mini.decode(successData);
					        	layer.close(index);
					        	 if(obj.type == 200){
					        		 var yes=step.nextStep();
						    	 }
						    	 if(obj.type == 100){
						    		 layer.alert(obj.msg, {
							 	    	  title:"失败",
							 	    	  icon:2,
							 	    	  skin:'layui-layer-lan',
							 	    	  closeBtn: 0
							 	    	  });
						    	 }
					        },
					        error: function (XMLHttpRequest, textStatus, errorThrown) {
					        	 layer.msg("错误", {time: 2000, icon:2},function(){
					        		 parent.layer.closeAll();
					        	 });
					        }
					    });
				  return false;
				});
		
	});	
	/**
	 * 验证手机号码
	 * 
	 * 移动号码段:139、138、137、136、135、134、150、151、152、157、158、159、182、183、187、188、147
	 * 联通号码段:130、131、132、136、185、186、145
	 * 电信号码段:133、153、180、189
	 * 
	 * @param cellphone
	 * @return
	 */
	function checkCellphone(cellphone) {
		 var regex = new RegExp("^((1[3-8][0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0-9]))\\d{8}$"); 
		 return regex.test(cellphone);
	}
	function openW(){
		var text = $("#fileHtml").text();
		layer.open({
			  type: 2,
			  title:text,
			  area: ['700px', '360px'],
			  fixed: false, //不固定
			  maxmin: true,
			  skin:'layui-layer-lan',
			  content: basePath+"users/uploadwindow"
			});
	}	
	function sendAgain(){
		var num = 60;
		var timeId = setInterval(function(){
			if(num==0){
				$("#LAY-user-getsmscode").text("获取验证码");
				$("#LAY-user-getsmscode").css("cursor","pointer");
				$("#LAY-user-getsmscode").css("color","#555");
				clearInterval(timeId);
				return;
			}
			$("#LAY-user-getsmscode").text(num+"秒后重获");
			$("#LAY-user-getsmscode").css("cursor","not-allowed");
			$("#LAY-user-getsmscode").css("color","#d2d2d2");
			num--;
		},1000);
	}
/*]]>*/
	</script>
</body>
</html>